#!/usr/bin/env python
# -*- coding: utf-8 -*-

__url__ = 'http://code.google.com/p/webpyte/'
__author__ = 'Nando Florestan'
__version__ = "0.0.4dev"
__license__ = 'BSD'
__dependencies__ = [
    ('bag', 'provides various utility methods and classes'),
    ('cherrypy >= 3.1.2',
     'vastly superior to the version used in TurboGears 1.0'),
    ('Genshi', 'a great XML templating language'),
    ('ipython', 'a smarter interpreter for administration'),
    ('Paste >= 1.7.2', 'evalexception shows rich, interactive stack traces'),
    ('Routes < 1.12', 'versatile URL dispatching'),
    ('SQLAlchemy >= 0.5.7', 'flexible ORM for your database needs'),
    ('TurboMail >= 3.0.3', 'assembles and sends out e-mails'),
    ('Unipath', 'object-oriented file and directory manipulation'),
    ('Markdown >= 2.0.3', 'nice text-to-HTML syntax'),
    ('BeautifulSoup == 3.0.8', 'parses and modifies HTML'),
    ('pexpect', 'talks to unix commands'),
]
dependencies_text = '''Webpyte is based on Python 2.6 (an extremely high
level programming language) and these Python libraries:

{0}'''.format('\n'.join(['* {0} - {1}'.format(name, descr) for name, descr \
    in __dependencies__]))

__doc__ = '''{0}

{1}
'''.format(__url__, dependencies_text)


import cherrypy
from unipath import Path
from loader import Loader
from warnings import warn as _warn


def flash(msg):
    cherrypy.session["flash"] = cherrypy.session.get("flash", "") + msg + "\n"


def has_flash():
    try:
        return cherrypy.session.get("flash", False)
    except AttributeError:
        return False  # because current app does not use sessions


def consume_flash():
    return cherrypy.session.pop("flash", "")


def warn_deprecated(message):
    _warn(message, DeprecationWarning, stacklevel=2)


class ShowUserThisException(Exception):
    """Throw this exception (usually from your model's properties) to
    let the gensher module know that the @page decorator should
    show this exception's message to the user via the error() method.
    """

# Make the Webpyte directory easily available
dir_wp = Path(__file__).absolute().parent
# dir_wp = os.path.dirname(os.path.abspath(__file__))

# Variables filled in by other modules
# Module wp_routes:
url = None
redirect = None
